#!/usr/bin/env bash

# Release 测试脚本：调用 builders/build_ios_export.sh
# 可通过预先设置环境变量 UNITY_EXE 覆盖 Unity 路径

LOG_TAG="[IOS-BUILD-TEST]"
log() { echo "${LOG_TAG} [$(date '+%Y-%m-%d %H:%M:%S')] $*"; }

buildType="RELEASE"
b ranch="master"
clean="true"

# 建议在 Git Bash/WSL 下使用正斜杠路径
projectPath="C:/WareHouse/chordroguelike"

if [[ -n "${UNITY_EXE:-}" ]]; then
  unity="$UNITY_EXE"
else
  unity="C:/Program Files/Unity/Hub/Editor/2022.3.61f1c1/Editor/Unity.exe"
fi

if [[ ! -f "$unity" ]]; then
  echo "未找到 Unity 可执行文件: $unity"
  echo "请设置环境变量 UNITY_EXE 指向 Unity.exe 或修改本脚本里的默认路径。"
  exit 1
fi

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

log "调用 build_ios_export.sh 开始"
bash "$script_dir/build_ios_export.sh" "$buildType" "$branch" "$clean" "$projectPath" "$unity" "$projectPath/Build/ios_build_log.txt"
exit_code=$?
log "调用结束，退出码: $exit_code"
exit $exit_code


